package com.quwan.app.controller;

import com.quwan.common.BaseController;
import com.quwan.common.result.ApiResult;
import com.quwan.common.result.PageResult;
import com.quwan.entity.TMemberClickNum;
import com.quwan.manager.service.MemberClickNumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;


/**
 * @author laozhang
 * @date 2022/05/28
 */
@Api(tags = "APP——用户点击事件——管理接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("app/memberClickNum")
public class AppMemberClickNumController extends BaseController {

    private final MemberClickNumService memberClickNumService;

    @ApiOperation("用户点击事件——增加(调一次接口对应点击数量+1)")
    @PostMapping("add/clickNum")
    public synchronized ApiResult<String> addClickNum(@ApiParam(value = "点击类型 1内容详情 2下单页面 3导航详情 4同城 5主页 6广场 7消息 8切换圈子 9我的 10待处理 " +
            "11待处理详情 12进行中 13进行中详情 14已完成 15已完成详情 16余额 17推广盈利 18发布技能 19实名认证",required = true) @RequestParam("type") Integer type) {
        TMemberClickNum clickNum = memberClickNumService.selectTMemberClickNumByCurrentTime();
        if(clickNum == null || clickNum.equals("")){
            clickNum = new TMemberClickNum();
            switch (type){
                case 1 : clickNum.setContentDetailNum(1);break;
                case 2 : clickNum.setOrderPageNum(1);break;
                case 3 : clickNum.setNavDetailNum(1);break;
                case 4 : clickNum.setCityNum(1);break;
                case 5 : clickNum.setPageNum(1);break;
                case 6 : clickNum.setSquareNum(1);break;
                case 7 : clickNum.setMessageNum(1);break;
                case 8 : clickNum.setCircleNum(1);break;
                case 9 : clickNum.setMyNum(1);break;
                case 10 : clickNum.setHandleNum(1);break;
                case 11 : clickNum.setHandleDetailNum(1);break;
                case 12 : clickNum.setRunNum(1);break;
                case 13 : clickNum.setRunDetailNum(1);break;
                case 14 : clickNum.setFinishNum(1);break;
                case 15 : clickNum.setFinishDetailNum(1);break;
                case 16 : clickNum.setMoneyNum(1);break;
                case 17 : clickNum.setExtendNum(1);break;
                case 18 : clickNum.setSkillNum(1);break;
                case 19 : clickNum.setRealNameNum(1);break;
            }
            clickNum.setCreateTime(LocalDate.now());
            memberClickNumService.insertTMemberClickNum(clickNum);
        }else{
            switch (type){
                case 1 : clickNum.setContentDetailNum(1+clickNum.getContentDetailNum());break;
                case 2 : clickNum.setOrderPageNum(1+clickNum.getOrderPageNum());break;
                case 3 : clickNum.setNavDetailNum(1+clickNum.getNavDetailNum());break;
                case 4 : clickNum.setCityNum(1+clickNum.getCityNum());break;
                case 5 : clickNum.setPageNum(1+clickNum.getPageNum());break;
                case 6 : clickNum.setSquareNum(1+clickNum.getSquareNum());break;
                case 7 : clickNum.setMessageNum(1+clickNum.getMessageNum());break;
                case 8 : clickNum.setCircleNum(1+clickNum.getCircleNum());break;
                case 9 : clickNum.setMyNum(1+clickNum.getMyNum());break;
                case 10 : clickNum.setHandleNum(1+clickNum.getHandleNum());break;
                case 11 : clickNum.setHandleDetailNum(1+clickNum.getHandleDetailNum());break;
                case 12 : clickNum.setRunNum(1+clickNum.getRunNum());break;
                case 13 : clickNum.setRunDetailNum(1+clickNum.getRunDetailNum());break;
                case 14 : clickNum.setFinishNum(1+clickNum.getFinishNum());break;
                case 15 : clickNum.setFinishDetailNum(1+clickNum.getFinishDetailNum());break;
                case 16 : clickNum.setMoneyNum(1+clickNum.getMoneyNum());break;
                case 17 : clickNum.setExtendNum(1+clickNum.getExtendNum());break;
                case 18 : clickNum.setSkillNum(1+clickNum.getSkillNum());break;
                case 19 : clickNum.setRealNameNum(1+clickNum.getRealNameNum());break;
            }
            memberClickNumService.updateTMemberClickNum(clickNum);
        }
        return ApiResult.success();
    }

}
